package com.bdqn.desiremall.serivce.admin;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.bdqn.desiremall.entity.Mall_AdminiStrator;
import com.bdqn.desiremall.entity.Mall_User;
import com.bdqn.desiremall.mapper.Mall_AdminiStratorMapper;
import com.bdqn.desiremall.mapper.Mall_UserMapper;
import com.desiremall.util.MyBatisUtil;

public class AdminServiceImpl implements AdminService {
	SqlSession session = MyBatisUtil.getSession();
	Mall_AdminiStrator strator = null;
	Mall_AdminiStratorMapper mapper = null;
	Mall_User mall_User = null;
	Mall_UserMapper mall_UserMapper = null;

	@Override
	public Mall_AdminiStrator Login(String admin, String password) {
		mapper = session.getMapper(Mall_AdminiStratorMapper.class);
		strator = mapper.findAdmin(admin, password);
		
		
			return strator;
		
		
	}

	@Override
	public List<Mall_User> userView(Mall_User user) {
		mall_UserMapper = session.getMapper(Mall_UserMapper.class);
		user = new Mall_User();
		List<Mall_User> userList = mall_UserMapper.getUserByInfo(user);
		return userList;
	}

	@Override
	public boolean defriendUser(int userId,int state) {
		mall_UserMapper = session.getMapper(Mall_UserMapper.class);
		mall_User = new Mall_User();
		mall_User.setUserId(userId);
		mall_User.setUserState(state);
		int i = mall_UserMapper.modifyUserInfo(mall_User);
		if (i > 0) {
			session.commit();
		return true;
		}
		return false;
	}
	
	
	

}
